package com.ruoyi.system.mapper;

import com.ruoyi.system.domain.UserScore;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface GradesMapper {

//  根据用户id查询用户的名字，部门，角色
    @Select("SELECT sys_user.user_id,sys_role.role_id,sys_user.nick_name,sys_role.role_name,sys_dept.dept_name \n"+
    "FROM sys_user,sys_dept,sys_role,sys_user_role \n"+
    "WHERE sys_user.dept_id=sys_dept.dept_id  \n"+
    "and sys_user_role.user_id=sys_user.user_id \n"+
    "and sys_user_role.role_id=sys_role.role_id and sys_user.user_id=#{userId}")
    public Map selectGradesuserById(Integer userId);

    ////查询评分并且是基层员工的数据 1代表能力评分，2代表潜力，13代表基层人员岗位评估
    @Select("SELECT * FROM rating_content,rating_category \n"+
    "WHERE rating_content.category=rating_category.category_Id and   category IN  \n"+
    "(SELECT rating_category.category_Id FROM rating_category WHERE  parent_Id in (1,7,13))")
    public List<Map> selectGrades();

//    要是前端提供身份id和岗位评分的话就走这个
//    @Select("SELECT * FROM rating_content,rating_category \n"+
//    "WHERE rating_content.category=rating_category.category_Id and   category IN  \n"+
//    "(SELECT rating_category.category_Id FROM rating_category WHERE  parent_Id=#{id} OR parent_Id in \n"+
//    "(SELECT rating_category.category_Id FROM rating_category WHERE  parent_Id=#{identityid}))")
//    public List<Map> selectGrades02(Integer id,Integer identityid);


//  查询评分并且是管理层员工的数据  1代表能力评分，2代表潜力评分，17代表管理人员岗位评估
    @Select("SELECT * FROM rating_content,rating_category \n"+
    "WHERE rating_content.category=rating_category.category_Id and   category IN  \n"+
    "(SELECT rating_category.category_Id FROM rating_category WHERE parent_Id in (1,7,17))")
    public List<Map> selectGrades01();


//  新增测评打分
    @Insert("INSERT INTO user_score(user_id,category_id,score,rating_Date,rater_num,assess_Date) \n" +
            "VALUES(#{userId},#{categoryId},#{score},#{ratingDate},#{raterNum},#{assessDate})")
    public void insertable(UserScore userScore);

//  新增是否评论
    @Insert("INSERT INTO evaluation_Status(user_id,status,assess_Date,rating_Date,rater_num) VALUES \n" +
            "(#{userid},#{status},#{assessdates},#{ratingdate},#{raternum})")
    public void inserevaluation(@Param("userid") Integer userid,
                                @Param("status") Integer status,
                                @Param("assessdates") String assessdates,
                                @Param("ratingdate") String ratingdate,
                                @Param("raternum") Integer raternum);
}
